#include <stdio.h>
#define XOR(a, b) ((                     \
                       (a) && (!(b))) || \
                   ((b) && (!(a))))
#define show(a) \
    printf(#a); \
    printf("%2d ", a);
int main()
{
    int bits = 4;
    int input;
    int s0, c0, s1, c1, x, y;
    char a[4];
    int i;
    for (input = 0; input < 0x10; input++)
    {
        for (i = 0; i < 4; i++)
        {
            a[i] = (input & (1 << i)) != 0;
            printf("%d ", a[i]);
        }
        printf("\t");
        s0 = XOR(a[0], a[1]);
        c0 = a[0] && a[1];
        x = XOR(a[2], a[3]);
        y = a[2] && a[3];
        s1 = XOR(x, c0);
        c1 = y || (x && c0);
        show(s0);
        show(c0);
        show(x);
        show(y);
        show(s1);
        show(c1);
        printf("\n");
    }
    return 0;
}